<html xmlns:th="http://www.thymeleaf.org"  
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"    
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">    
<html>
<head th:include="common/common::header">
<meta charset="UTF-8">

<style type="text/css">
#index {
	padding: 15px;
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	opacity: 0;
	font-size: 12px;
}

.index-l {
	padding: 10px;
	width: 48%;
	overflow: auto;
}
</style>
</head>

<body>
	<div id="index">
		<form id="NavigationDto_form" class="easyui-form" method="post" data-options="novalidate:true">
		<div class="contentWrapper">
			<!--tab-->
			<div class="index-l">
				<div id="tt" class="easyui-tabs" data-options="tabHeight:31"
					style="width: 100%;">
					<div title="基础配置" style="padding: 20px; display: none;">
						<div class="contentWrapper">
						<input type="hidden" name="id" th:value="${ContentDto.id}">
							<div class="form-item">
								<label for="" class="label-top">文章标题：</label> <input
									id="" name="title" class="easyui-validatebox easyui-textbox"
									data-options="required:true" style="width: 90%;"
									th:value="${ContentDto.title }">

							</div>
							<br>
							<div class="form-item">
								<label for="" class="label-top">文章类型：</label> <input id=""
									class="easyui-validatebox easyui-combobox" name="type" 
									data-options="required:false,url:'/app/navigation/load_list',valueField:'id',textField:'title'" style="width: 90%;" th:value="${ContentDto.type }">

							</div>
							<br>
							<div class="form-item">
								<label for="" class="label-top">文章排序：</label> <input id=""
									class="easyui-validatebox easyui-numberbox" name="sort"
									data-options="required:false,url:''" style="width: 90%;" th:value="${ContentDto.sort }">

							</div>
							<br>
								<div class="form-item">
									<label for="" class="label-top">是否推荐：</label> <input
										id="" class="easyui-combobox"
										data-options="textField:'text',valueField:'id',editable:false,panelHeight:null,url:'/system/common/load_enabled.do'" name="recommend"
										style="width: 90%;" th:value="${ContentDto.recommend }">
								</div>
								<br>
								<div class="form-item">
									<label for="" class="label-top">是否置顶：</label> <input
										id="" class="easyui-combobox"
										data-options="textField:'text',valueField:'id',editable:false,panelHeight:null,url:'/system/common/load_enabled.do'" name="top"
										style="width: 90%;" th:value="${ContentDto.top }">
								</div>
							<br>
								<div class="form-item">
									<label for="" class="label-top">是否可用：</label> <input
										id="" class="easyui-combobox"
										data-options="textField:'text',valueField:'id',editable:false,panelHeight:null,url:'/system/common/load_enabled.do'" name="enabled"
										style="width: 90%;" th:value="${ContentDto.enabled }">
								</div>
								<br>
								<div class="form-item">
								<input type="hidden" name="cover" id="ContentDto_cover" th:value="${ContentDto.cover}">
										<div id="container">
									            <div id="uploader">
									                <div class="queueList">
									                    <div id="dndArea" class="placeholder">
									                        <div id="filePicker"></div>
									                        <p>或将封面体拖到这里，单次最多可选1张</p>
									                    </div>
									                </div>
									                <div class="statusBar" style="display:none;">
									                    <div class="progress">
									                        <span class="text">0%</span>
									                        <span class="percentage"></span>
									                    </div><div class="info"></div>
									                    <div class="btns">
									                        <div id="filePicker2"></div><div class="uploadBtn">开始上传</div>
									                    </div>
									                </div>
									            </div>
        								</div>
								</div>
					</div>
				</div>
				
				<div title="文章编辑"
						style="overflow: auto; padding: 20px; display: none;">
						<div class="form-item">
	                        <script id="editor" type="text/plain" style="width:100%;height:100%;"></script>
	                        <input type="hidden" name="text" id="ContentDto_text">
	                    </div>
				</div>
			</div>
					<div style="margin-top: 1%; padding-left: 37.5%">
						<a href="javascript:void(0)" onclick="submitForm()" class="easyui-linkbutton"data-options="iconCls:'fa fa-floppy-o'"style="height: 30px; border-left-width: 1px;">保存</a> 
						<a id="DictionaryDto_close" onclick="closedialog(this)"href="javascript:void(0)" class="easyui-linkbutton"data-options="iconCls:'fa fa-ban'"style="height: 30px; border-left-width: 1px;">取消</a>
					</div>
		</form>
	</div>
<script type="text/javascript" src="/base/webuploader/webuploader.min.js"></script>
<link rel="stylesheet" href="/base/webuploader/webuploader.css">
<script type="text/javascript" src="/base/webuploader/upload.js"></script>
<script type="text/javascript" src="/base/webuploader/underscore-min.js"></script>
<link rel="stylesheet" href="/base/webuploader/style.css">
<script type="text/javascript" charset="utf-8" src="/base/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/base/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="/base/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
var arr = [];
function submitForm(){
	var text = UE.getEditor('editor').getContent();
	$("#ContentDto_cover").val(arr[0])
	$("#ContentDto_text").val(text)
	$('#NavigationDto_form').form('submit',{
		url:'/app/content/save.do',
		onSubmit:function(){
			return $(this).form('enableValidation').form('validate');
		},
		 success: function (data) {
			 if (JSON.parse(data).status ==200) {
				 	break_save();
				} else {
						$.messager.alert('消息',JSON.parse(data).msg);
				}
		 }
	});
}
function escape2Html(str) {
	 var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
	 return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
	}
var ue = UE.getEditor('editor');
ue.addListener("ready", function () {  
	 var news_content = '[[${ContentDto.text }]]';
	 var text = escape2Html(news_content);
		if(text!=null) {
		ue.setContent(text);
	}
}); 
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
UE.Editor.prototype.getActionUrl = function(action) {
if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
    var url = 'http://127.0.0.1:8082/common/upload?attachmentsType=2';
    return url;
} else if (action == 'uploadvideo') {
    return 'http://127.0.0.1:8082/common/upload?attachmentsType=2';
} else {
    return this._bkGetActionUrl.call(this, action);
}
}
</script>
</body>
</html>